package com.gome.transactiontree.sample.case3;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gome.transactiontree.api.TransactionNode;

@Service
public class BusinessA {

	private static final Logger LOG = LoggerFactory.getLogger(BusinessA.class);
	
	@Autowired
	private BusinessBProxy businessBProxy;

	@TransactionNode(commit = "a1_confirm(#args[0])", rollback = "a1_cannel")
	public String a1(String txid, String p2) {
		LOG.info("TCC BusinessA.a1({},{})", txid, p2);
		
		businessBProxy.b1(txid, p2);

		return txid;
	}

	public void a1_confirm(String txid) {
		LOG.info("TCC BusinessA.a1_confirm({})", txid);
	}
	
	public void a1_cannel(String txid, String p2) {
		LOG.info("TCC BusinessA.a1_cannel({},{})", txid, p2);
	}
}